from data_structures.linked_list.positional_list import PositionalList
def Algorithm_spide(L):
    head1=L.first()
    head2=L.first()
    times=len(L)//2

    for i in range(times):
        head2=L.after(head2)
        #print(head2.element())
    temp = PositionalList()

    while(times>=1) :
        temp._next=head1._node
        head1=L.after(head1)
        temp=temp._next

        temp._next=head2._node
        head2=L.after(head2)
        temp=temp._next

        times-=1

    return L


if __name__ == '__main__':
    L = PositionalList()
    L.add_first(12)
    L.add_first(15)
    L.add_first(10)
    L.add_first(5)
    L.add_first(30)
    L.add_first(49)
    L.add_first(48)
    L.add_first(50)
    print(L)
    res = Algorithm_spide(L)
    print('洗牌后：'+ str(res))